home *** CD-ROM | disk | FTP | other *** search
/ Mac100% 1998 November / MAC100-1998-11.ISO.7z / MAC100-1998-11.ISO / オンラインソフト定点観測 / ユーティリティ / Mops 3.2.sea / Mops 3.2 / Mops ƒ / PathsMod.txt < prev    next >
Text File  |  1997-11-05  |  2KB  |  77 lines

  1. ¥ We call this module if a list of HFS path designators is to be used to
  2. ¥ find a file.  First we grab the file with the list
  3. ¥ of path designators (one per line).  For each designator we prepend
  4. ¥ it to the given filename, and attempt to open the file.  We keep
  5. ¥ going until either the open succeeds or we run out of path designators.
  6. ¥ If the open succeeds we leave the name in the fcb set to the full
  7. ¥ path name.  If the open fails we restore the name to what it was.
  8.  
  9. objPtr        PATHS_F    class_is  file
  10. objHandle    PATHS_HDL
  11.  
  12. string        NAME
  13. string        FULLNAME
  14. string        PDS
  15.  
  16. local    OWP  { fcb mode ¥ ret? -- rc }
  17.  
  18. : OPENLOOP
  19.     BEGIN              ¥ Loop over path designators
  20.         len: pds
  21.         NIF                                        ¥ Not found
  22.             all: name  fcb name: file            ¥ Restore orig name
  23.             FNF  EXIT
  24.         THEN
  25.         RET  chsearch: pds  -> ret?
  26.         pds ->: fullName  name  $add: fullName
  27.         all: fullName  fcb name: class_as> file
  28.         fcb openReadOnly: class_as> file  NIF 0  EXIT  THEN        ¥ Found
  29.         step: pds  ret? negate skip: pds
  30.     AGAIN  ;
  31.  
  32.  
  33. :loc OWP
  34.     reset: pds
  35.     len: pds  NIF  FNF  EXIT  THEN
  36.             ¥ If no paths, we return a "file not found" error.
  37.     false -> use_paths?        ¥ so we don't get recursively entered!
  38.     getName: [ fcb ]
  39.     put: name  new: fullName
  40.     openLoop
  41.     release: name  release: fullName
  42.     true -> use_paths?
  43. ;loc
  44.  
  45.  
  46. : GETPATHS    ¥ ( addr len -- )
  47.     true -> use_paths?        ¥ This becomes the default now
  48.                     ¥  that GETPATHS has been called
  49.     keep: pathsMod
  50.     nil?: pds  IF  new: pds  ELSE  clear: pds  THEN
  51.     release: paths_hdl  ['] file  newObj: paths_hdl
  52.     obj: paths_hdl  -> paths_f
  53.     name: paths_f  openReadOnly: paths_f
  54.     IF
  55.         msg# 133        ¥ Warning - couldn't find paths file
  56.         release: paths_hdl  nilP -> paths_f  EXIT
  57.     THEN
  58.     size: paths_f  setsize: pds
  59.     all: pds  read: paths_f  drop
  60.     close: paths_f  drop  releaseObj: paths_hdl  ;
  61.  
  62.  
  63. : .PATHS  { ¥ ret? -- }
  64.     nil?: pds  ?EXIT
  65.     reset: pds
  66.     BEGIN
  67.         len: pds  0EXIT
  68.         RET  chsearch: pds  -> ret?
  69.         get: pds  type  cr
  70.         step: pds  ret? negate skip: pds
  71.     AGAIN  ;
  72.  
  73.  
  74. : REL    release: pds  ;
  75.  
  76. ' rel  setRelease
  77.